﻿namespace Forms
{
    using Forms.My;

    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;

    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class frmFA_Add : Form
    {
        [AccessedThroughProperty("butAbort")]
        private Button _butAbort;
        [AccessedThroughProperty("butOk")]
        private Button _butOk;
        [AccessedThroughProperty("cmbAbloesen")]
        private ComboBox _cmbAbloesen;
        [AccessedThroughProperty("cmbFarbe")]
        private ComboBox _cmbFarbe;
        [AccessedThroughProperty("Label1")]
        private Label _Label1;
        [AccessedThroughProperty("Label2")]
        private Label _Label2;
        [AccessedThroughProperty("Label3")]
        private Label _Label3;
        [AccessedThroughProperty("Label4")]
        private Label _Label4;
        [AccessedThroughProperty("Label5")]
        private Label _Label5;
        [AccessedThroughProperty("Label6")]
        private Label _Label6;
        [AccessedThroughProperty("txtAutoTage")]
        private TextBox _txtAutoTage;
        [AccessedThroughProperty("txtKundeAuto")]
        private TextBox _txtKundeAuto;
        [AccessedThroughProperty("txtKurzbezeichnung")]
        private TextBox _txtKurzbezeichnung;
        [AccessedThroughProperty("txtName")]
        private TextBox _txtName;
        private int CurrentFAId;

        public frmFA_Add()
        {
            base.Load += new EventHandler(this.frmFA_Add_Load);
            this.CurrentFAId = -1;
            this.InitializeComponent();
        }

        private void butAbort_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void butOk_Click(object sender, EventArgs e)
        {
            switch (MyProject.Forms.frmFA.fMode)
            {
                case frmFA.fDetailMode.fEdit:
                {
                    string[] strArray = MyProject.Forms.frmFA.ListBoxFA.SelectedItem.ToString().Split(new char[] { ',' });
                    DataRow[] rowArray = MyProject.Forms.Main.cs.Table_Finanzierungsarten.Select("FA_ID = " + strArray[2]);
                    rowArray[0]["FA_KBz"] = this.txtKurzbezeichnung.Text;
                    rowArray[0]["FA_Name"] = this.txtName.Text;
                    rowArray[0]["FA_Color"] = this.cmbFarbe.SelectedItem.ToString();
                    rowArray[0]["FA_KundeAuto"] = this.txtKundeAuto.Text;
                    rowArray[0]["FA_Tage_Auto"] = Convert.ToByte(this.txtAutoTage.Text);
                    rowArray[0]["FA_Abloesen"] = this.cmbAbloesen.SelectedIndex;
                    break;
                }
                case frmFA.fDetailMode.fNew:
                {
                    DataRow row = MyProject.Forms.Main.cs.Table_Finanzierungsarten.NewRow();
                    row["FA_Kbz"] = this.txtKurzbezeichnung.Text;
                    row["FA_Name"] = this.txtName.Text;
                    row["FA_Color"] = this.cmbFarbe.SelectedItem.ToString();
                    row["FA_KundeAuto"] = this.txtKundeAuto.Text;
                    row["FA_Abloesen"] = this.cmbAbloesen.SelectedIndex;
                    row["FA_Tage_Auto"] = 0;
                    MyProject.Forms.Main.cs.Table_Finanzierungsarten.Rows.Add(row);
                    break;
                }
            }
            this.Close();
            MyProject.Forms.frmFA.UpdateList();
        }

        private void cmbFarbe_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index >= 0)
            {
                SolidBrush brush = new SolidBrush(Color.FromName(this.cmbFarbe.Items[e.Index].ToString()));
                e.Graphics.FillRectangle(brush, (int) (e.Bounds.X + 1), (int) (e.Bounds.Y + 1), (int) (e.Bounds.Width - 3), (int) (e.Bounds.Height - 3));
                e.Graphics.DrawRectangle(Pens.Black, (int) (e.Bounds.X + 1), (int) (e.Bounds.Y + 1), (int) (e.Bounds.Width - 3), (int) (e.Bounds.Height - 3));
            }
        }

       

        private void frmFA_Add_Load(object sender, EventArgs e)
        {
            switch (MyProject.Forms.frmFA.fMode)
            {
                case frmFA.fDetailMode.fEdit:
                    if (MyProject.Forms.frmFA.ListBoxFA.SelectedItem != null)
                    {
                        string[] strArray = MyProject.Forms.frmFA.ListBoxFA.SelectedItem.ToString().Split(new char[] { ',' });
                        DataRow[] rowArray = MyProject.Forms.Main.cs.Table_Finanzierungsarten.Select("FA_ID = " + strArray[2]);
                        this.CurrentFAId = Conversions.ToInteger(rowArray[0]["FA_ID"]);
                        this.txtKurzbezeichnung.Text = Conversions.ToString(rowArray[0]["FA_KBz"]);
                        this.txtName.Text = Conversions.ToString(rowArray[0]["FA_Name"]);
                        this.txtKundeAuto.Text = Conversions.ToString(rowArray[0]["FA_KundeAuto"]);
                        this.txtAutoTage.Text = Conversions.ToString(rowArray[0]["FA_Tage_Auto"]);
                        this.cmbFarbe.SelectedIndex = this.cmbFarbe.FindString(Conversions.ToString(rowArray[0]["FA_Color"]));
                        this.cmbAbloesen.SelectedIndex = Conversions.ToInteger(rowArray[0]["FA_Abloesen"]);
                    }
                    this.Text = "Bearbeiten";
                    break;

                case frmFA.fDetailMode.fNew:
                    this.txtKurzbezeichnung.Text = "";
                    this.txtName.Text = "";
                    this.txtKundeAuto.Text = "";
                    this.cmbFarbe.SelectedIndex = 0;
                    this.cmbAbloesen.SelectedIndex = 0;
                    this.txtAutoTage.Text = Conversions.ToString(0);
                    this.CurrentFAId = -1;
                    this.Text = "Neu";
                    break;
            }
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            this.butOk = new Button();
            this.txtKurzbezeichnung = new TextBox();
            this.Label1 = new Label();
            this.Label2 = new Label();
            this.txtName = new TextBox();
            this.cmbFarbe = new ComboBox();
            this.Label3 = new Label();
            this.butAbort = new Button();
            this.txtKundeAuto = new TextBox();
            this.Label4 = new Label();
            this.Label5 = new Label();
            this.cmbAbloesen = new ComboBox();
            this.Label6 = new Label();
            this.txtAutoTage = new TextBox();
            this.SuspendLayout();
            Point point = new Point(0xbd, 0xf6);
            this.butOk.Location = point;
            this.butOk.Name = "butOk";
            Size size = new Size(0x71, 0x1b);
            this.butOk.Size = size;
            this.butOk.TabIndex = 12;
            this.butOk.Text = "Ok";
            this.butOk.UseVisualStyleBackColor = true;
            point = new Point(0xb1, 15);
            this.txtKurzbezeichnung.Location = point;
            this.txtKurzbezeichnung.MaxLength = 4;
            this.txtKurzbezeichnung.Name = "txtKurzbezeichnung";
            size = new Size(130, 20);
            this.txtKurzbezeichnung.Size = size;
            this.txtKurzbezeichnung.TabIndex = 13;
            this.Label1.AutoSize = true;
            point = new Point(0x52, 15);
            this.Label1.Location = point;
            this.Label1.Name = "Label1";
            size = new Size(0x59, 13);
            this.Label1.Size = size;
            this.Label1.TabIndex = 14;
            this.Label1.Text = "Kurzbezeichnung";
            this.Label2.AutoSize = true;
            point = new Point(0x88, 50);
            this.Label2.Location = point;
            this.Label2.Name = "Label2";
            size = new Size(0x23, 13);
            this.Label2.Size = size;
            this.Label2.TabIndex = 15;
            this.Label2.Text = "Name";
            point = new Point(0xb1, 50);
            this.txtName.Location = point;
            this.txtName.Name = "txtName";
            size = new Size(130, 20);
            this.txtName.Size = size;
            this.txtName.TabIndex = 0x10;
            this.cmbFarbe.DrawMode = DrawMode.OwnerDrawFixed;
            this.cmbFarbe.DropDownStyle = ComboBoxStyle.DropDownList;
            this.cmbFarbe.FormattingEnabled = true;
            this.cmbFarbe.Items.AddRange(new object[] { 
                "White", "DarkGray", "LightGray", "IndianRed", "LightCoral", "RosyBrown", "Coral", "SandyBrown", "Tan", "NavajoWhite", "Khaki", "DarkKhaki", "YellowGreen", "PaleGreen", "MediumSeaGreen", "MediumAquamarine", 
                "PaleTurquoise", "SkyBlue", "LightSteelBlue", "MediumPurple", "Plum", "HotPink"
             });
            point = new Point(0xb1, 0x55);
            this.cmbFarbe.Location = point;
            this.cmbFarbe.Name = "cmbFarbe";
            size = new Size(130, 0x15);
            this.cmbFarbe.Size = size;
            this.cmbFarbe.TabIndex = 0x11;
            this.Label3.AutoSize = true;
            point = new Point(0x89, 0x55);
            this.Label3.Location = point;
            this.Label3.Name = "Label3";
            size = new Size(0x22, 13);
            this.Label3.Size = size;
            this.Label3.TabIndex = 0x12;
            this.Label3.Text = "Farbe";
            point = new Point(0x4a, 0xf6);
            this.butAbort.Location = point;
            this.butAbort.Name = "butAbort";
            size = new Size(0x71, 0x1b);
            this.butAbort.Size = size;
            this.butAbort.TabIndex = 0x13;
            this.butAbort.Text = "Abbrechen";
            this.butAbort.UseVisualStyleBackColor = true;
            point = new Point(0xb1, 0x7a);
            this.txtKundeAuto.Location = point;
            this.txtKundeAuto.Name = "txtKundeAuto";
            size = new Size(130, 20);
            this.txtKundeAuto.Size = size;
            this.txtKundeAuto.TabIndex = 20;
            this.Label4.AutoSize = true;
            point = new Point(0x47, 0x7a);
            this.Label4.Location = point;
            this.Label4.Name = "Label4";
            size = new Size(100, 13);
            this.Label4.Size = size;
            this.Label4.TabIndex = 0x15;
            this.Label4.Text = "Kunden Nr (Autom.)";
            this.Label5.AutoSize = true;
            point = new Point(0x7e, 0x9e);
            this.Label5.Location = point;
            this.Label5.Name = "Label5";
            size = new Size(0x2d, 13);
            this.Label5.Size = size;
            this.Label5.TabIndex = 0x16;
            this.Label5.Text = "Ablösen";
            this.cmbAbloesen.DropDownStyle = ComboBoxStyle.DropDownList;
            this.cmbAbloesen.FormattingEnabled = true;
            this.cmbAbloesen.Items.AddRange(new object[] { "kein", "BMW-Bank" });
            point = new Point(0xb1, 0x9e);
            this.cmbAbloesen.Location = point;
            this.cmbAbloesen.Name = "cmbAbloesen";
            size = new Size(130, 0x15);
            this.cmbAbloesen.Size = size;
            this.cmbAbloesen.TabIndex = 0x17;
            this.Label6.AutoSize = true;
            point = new Point(15, 0xc7);
            this.Label6.Location = point;
            this.Label6.Name = "Label6";
            size = new Size(0x9a, 13);
            this.Label6.Size = size;
            this.Label6.TabIndex = 0x19;
            this.Label6.Text = "Tage nach RG-Datum (Autom.)";
            point = new Point(0xb1, 0xc4);
            this.txtAutoTage.Location = point;
            this.txtAutoTage.MaxLength = 4;
            this.txtAutoTage.Name = "txtAutoTage";
            size = new Size(30, 20);
            this.txtAutoTage.Size = size;
            this.txtAutoTage.TabIndex = 0x18;
            SizeF ef = new SizeF(6f, 13f);
            this.AutoScaleDimensions = ef;
            this.AutoScaleMode = AutoScaleMode.Font;
            size = new Size(0x174, 300);
            this.ClientSize = size;
            this.Controls.Add(this.Label6);
            this.Controls.Add(this.txtAutoTage);
            this.Controls.Add(this.cmbAbloesen);
            this.Controls.Add(this.Label5);
            this.Controls.Add(this.Label4);
            this.Controls.Add(this.txtKundeAuto);
            this.Controls.Add(this.butAbort);
            this.Controls.Add(this.Label3);
            this.Controls.Add(this.cmbFarbe);
            this.Controls.Add(this.txtName);
            this.Controls.Add(this.Label2);
            this.Controls.Add(this.Label1);
            this.Controls.Add(this.txtKurzbezeichnung);
            this.Controls.Add(this.butOk);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "frmFA_Add";
            this.ShowIcon = false;
            this.ShowInTaskbar = false;
            this.StartPosition = FormStartPosition.CenterParent;
            this.Text = "Finanzierungsart Details";
            this.TopMost = true;
            this.ResumeLayout(false);
            this.PerformLayout();
        }

        private void txtAutoTage_Validating(object sender, CancelEventArgs e)
        {
            e.Cancel = false;
            if (this.txtAutoTage.Text.Length > 0)
            {
                byte num;
                if (byte.TryParse(this.txtAutoTage.Text, out num))
                {
                    if ((num < 0) | (num > 4))
                    {
                        e.Cancel = true;
                        Interaction.MsgBox("Sie müssen einen gültigen Wert für die automatische Ablöseberechnung angeben (0-4).", MsgBoxStyle.Exclamation, "Fehler");
                    }
                    else if (num > 0)
                    {
                        foreach (DataRow row in MyProject.Forms.Main.cs.Table_Finanzierungsarten.Select("FA_Tage_Auto>0"))
                        {
                            if (Operators.ConditionalCompareObjectNotEqual(row["FA_ID"], this.CurrentFAId, false))
                            {
                                Interaction.MsgBox(Operators.AddObject(Operators.AddObject(Operators.AddObject("Es existiert bereits einen Finanzierungsart mit automatischer Zuweisung über Tage: ", row["FA_Name"]), "\r\n"), "Sie können nur eine Finanzierungsart über Tage zuweisen lassen!"), MsgBoxStyle.Exclamation, "Fehler");
                                e.Cancel = true;
                            }
                        }
                    }
                }
                else
                {
                    e.Cancel = true;
                    Interaction.MsgBox("Sie müssen einen gültigen Wert für die automatische Ablöseberechnung angeben (0-4).", MsgBoxStyle.Exclamation, "Fehler");
                }
            }
            else
            {
                e.Cancel = false;
                this.txtAutoTage.Text = Conversions.ToString(0);
            }
        }

        internal virtual Button butAbort
        {
            [DebuggerNonUserCode]
            get
            {
                return this._butAbort;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.butAbort_Click);
                if (this._butAbort != null)
                {
                    this._butAbort.Click -= handler;
                }
                this._butAbort = value;
                if (this._butAbort != null)
                {
                    this._butAbort.Click += handler;
                }
            }
        }

        internal virtual Button butOk
        {
            [DebuggerNonUserCode]
            get
            {
                return this._butOk;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.butOk_Click);
                if (this._butOk != null)
                {
                    this._butOk.Click -= handler;
                }
                this._butOk = value;
                if (this._butOk != null)
                {
                    this._butOk.Click += handler;
                }
            }
        }

        internal virtual ComboBox cmbAbloesen
        {
            [DebuggerNonUserCode]
            get
            {
                return this._cmbAbloesen;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._cmbAbloesen = value;
            }
        }

        internal virtual ComboBox cmbFarbe
        {
            [DebuggerNonUserCode]
            get
            {
                return this._cmbFarbe;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                DrawItemEventHandler handler = new DrawItemEventHandler(this.cmbFarbe_DrawItem);
                if (this._cmbFarbe != null)
                {
                    this._cmbFarbe.DrawItem -= handler;
                }
                this._cmbFarbe = value;
                if (this._cmbFarbe != null)
                {
                    this._cmbFarbe.DrawItem += handler;
                }
            }
        }

        internal virtual Label Label1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label1 = value;
            }
        }

        internal virtual Label Label2
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label2;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label2 = value;
            }
        }

        internal virtual Label Label3
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label3;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label3 = value;
            }
        }

        internal virtual Label Label4
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label4;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label4 = value;
            }
        }

        internal virtual Label Label5
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label5;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label5 = value;
            }
        }

        internal virtual Label Label6
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label6;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label6 = value;
            }
        }

        internal virtual TextBox txtAutoTage
        {
            [DebuggerNonUserCode]
            get
            {
                return this._txtAutoTage;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                CancelEventHandler handler = new CancelEventHandler(this.txtAutoTage_Validating);
                if (this._txtAutoTage != null)
                {
                    this._txtAutoTage.Validating -= handler;
                }
                this._txtAutoTage = value;
                if (this._txtAutoTage != null)
                {
                    this._txtAutoTage.Validating += handler;
                }
            }
        }

        internal virtual TextBox txtKundeAuto
        {
            [DebuggerNonUserCode]
            get
            {
                return this._txtKundeAuto;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._txtKundeAuto = value;
            }
        }

        internal virtual TextBox txtKurzbezeichnung
        {
            [DebuggerNonUserCode]
            get
            {
                return this._txtKurzbezeichnung;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._txtKurzbezeichnung = value;
            }
        }

        internal virtual TextBox txtName
        {
            [DebuggerNonUserCode]
            get
            {
                return this._txtName;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._txtName = value;
            }
        }
    }
}

